﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DisplayReadingClient
{
    /// <summary>
    /// 通讯数据
    /// </summary>
    public class ComData
    {
        /// <summary>
        /// 
        /// </summary>
        public EnumCom com { get; set; }

        /// <summary>
        /// 数据数量 开几个连接
        /// </summary>
        public int dataCount { get; set; }

        /// <summary>
        /// 帧数
        /// </summary>
        public int fps { get; set; }

        /// <summary>
        /// 缓存大小
        /// </summary>
        public int cacheSize { get; set; } = 65536;

        /// <summary>
        /// 开始端口
        /// </summary>
        public int startPort { get; set; }
    }

    public enum EnumCom
    {
        non,
        ini,
        heart,
    }
    public class JsonHelp
    {
        /// <summary>
        /// 转字符串
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static string ToString<T>(T obj)
        {
            return Newtonsoft.Json.JsonConvert.SerializeObject(obj);
        }
        /// <summary>
        /// 转字符串
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static T ToObj<T>(string str)
        {
            return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(str);
        }
    }
}
